#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<vector<int>> points(n,vector<int>(2));
	for(int i=0;i<n;i++){
		cin>>points[i][0]>>points[i][1];
	}
	
	sort(points.begin(), points.end(), [](const vector<int>& u, const vector<int>& v) {
        return u[1] < v[1];
    });
    int pos = points[0][1];
    int ans = 1;
    for (const vector<int>& balloon: points) {
        if (balloon[0] > pos) {
            pos = balloon[1];
            ++ans;
        }
    }
    cout<<ans;

    return 0;
}


